package cn.chinaiptv.apkmanager.bean;

import java.io.Serializable;

import net.sf.json.JSONObject;

public class LauncherAPK implements Serializable {
	
	/*
	epgcheck_id INT(10) NOT NULL AUTO_INCREMENT,
	epgcheck_header VARCHAR(100) NOT NULL,
	epgcheck_platform VARCHAR(100)NOT NULL,
	epgcheck_option VARCHAR(100) NOT NULL,
	epgcheck_body TEXT NOT NULL,
	epgcheck_app VARCHAR(100)NOT NULL,
	epgcheck_code VARCHAR(100)NOT NULL,
	epgcheck_version VARCHAR(100)NOT NULL,
	epgcheck_platform1 VARCHAR(100)NOT NULL,
	epgcheck_url VARCHAR(100) NOT NULL,
	epgcheck_status INT NOT NULL, 
	 */
     private int idInClass;
     private String header;
     private String platform ;
     private String option;
     private String body;
     private String app;
     private String code;
     private String version;
     private String platformInBody;
     private String url;
     private String status;
     
     
     
	public LauncherAPK() {
		super();
	}
	public LauncherAPK(String header, String platform, String option,
			String body, String app, String code, String version,
			String platformInBody, String url, String status) {
		super();
		this.header = header;
		this.platform = platform;
		this.option = option;
		this.body = body;
		this.app = app;
		this.code = code;
		this.version = version;
		this.platformInBody = platformInBody;
		this.url = url;
		this.status = status;
	}
	
	public void generateLauncherAPKObjectFromJsonStr(String jsonStr){
		   
		   JSONObject json = JSONObject.fromObject(jsonStr);
		   JSONObject headerJson = (JSONObject) json.getJSONObject("header");
		   //存入数据库的platform
		   this.platform = headerJson.getString("platform");
		   //存入数据库的option
		   this.option = headerJson.getString("option");
		   JSONObject bodyJson = json.getJSONObject("body");
		   JSONObject appJson = bodyJson.getJSONObject("app");
		   
		   //存入数据库的code
		  this.code = appJson.getString("code");
		   //存入数据库的version
		  this.version = appJson.getString("version");
		   //存入数据库的platform
		  this.platformInBody = appJson.getString("platform");
		   //存入数据库的url
		   this.url = appJson.getString("url");
		   
	} 
	
	
	//用来生成第5个接口请求使用的json数据
	public String  generateLauncherAPKNotifyJsonStr(){
		//设置option = apksubmitnotify
		this.option = "apksubmitnotify";
		JSONObject json = new JSONObject();
		JSONObject headerJson = new JSONObject();
		JSONObject bodyJson = new JSONObject();
		JSONObject appJson = new JSONObject();
		headerJson.put("platform", this.platform);
		headerJson.put("option",this.option);
		appJson.put("code", this.code);
		appJson.put("status", this.status);
		bodyJson.put("app", appJson);
		json.put("header", headerJson);
		json.put("body",bodyJson);
		return json.toString();
	}
	
	
	public int getId() {
		return idInClass;
	}
	public void setId(int id) {
		this.idInClass = id;
	}
	public String getHeader() {
		return header;
	}
	public void setHeader(String header) {
		this.header = header;
	}
	public String getPlatform() {
		return platform;
	}
	public void setPlatform(String platform) {
		this.platform = platform;
	}
	public String getOption() {
		return option;
	}
	public void setOption(String option) {
		this.option = option;
	}
	public String getBody() {
		return body;
	}
	public void setBody(String body) {
		this.body = body;
	}
	public String getApp() {
		return app;
	}
	public void setApp(String app) {
		this.app = app;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public String getPlatformInBody() {
		return platformInBody;
	}
	public void setPlatformInBody(String platformInBody) {
		this.platformInBody = platformInBody;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	
	
	

}
